PAPER_NAME = critter_proposal
TEXFILES=$(PAPER_NAME).tex TEXT/*
BIBFILES=../critter.bib
DVIPS_PRINTER_OPTS = -t Letter -f -Ppdf -G0
DVIPS_FILE_OPTS = -Z 
PS2PDF = ps2pdf14
PS2PDF_OPTS = -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4

all : $(PAPER_NAME).pdf $(PAPER_NAME)_1page_summary.pdf $(PAPER_NAME)_transition_phase.pdf
dvi : $(PAPER_NAME).dvi $(PAPER_NAME)_1page_summary.dvi $(PAPER_NAME)_transition_phase.dvi
ps  : $(PAPER_NAME).ps $(PAPER_NAME)_1page_summary.ps $(PAPER_NAME)_transition_phase.ps
pdf : $(PAPER_NAME).pdf $(PAPER_NAME)_1page_summary.pdf $(PAPER_NAME)_transition_phase.pdf

# On Macs you can do "make paper": compiles paper *and* opens paper in preferred PDF viewer.
paper : $(PAPER_NAME).pdf
	open $(PAPER_NAME).pdf

summary: $(PAPER_NAME)_1page_summary.pdf
	open $(PAPER_NAME)_1page_summary.pdf

transitions: $(PAPER_NAME)_transition_phase.pdf
	open $(PAPER_NAME)_transition_phase.pdf

$(PAPER_NAME).dvi : $(TEXFILES) $(BIBFILES)
	latex $(PAPER_NAME) && bibtex $(PAPER_NAME) && latex $(PAPER_NAME) && latex $(PAPER_NAME)

$(PAPER_NAME)_1page_summary.dvi: TEXT/summary.tex TEXT/preamble.tex $(BIBFILES)
	latex $(PAPER_NAME)_1page_summary

$(PAPER_NAME)_transition_phase.dvi: TEXT/summary.tex TEXT/preamble.tex $(BIBFILES)
	latex $(PAPER_NAME)_transition_phase
	
$(PAPER_NAME).ps: $(PAPER_NAME).dvi $(TEXFILES)
	dvips $(DVIPS_PRINTER_OPTS) $(DVIPS_FILE_OPTS) $(PAPER_NAME).dvi >$(PAPER_NAME).ps

$(PAPER_NAME)_1page_summary.ps: $(PAPER_NAME)_1page_summary.dvi $(TEXFILES)
	dvips $(DVIPS_PRINTER_OPTS) $(DVIPS_FILE_OPTS) $(PAPER_NAME)_1page_summary.dvi >$(PAPER_NAME)_1page_summary.ps

$(PAPER_NAME)_transition_phase.ps: $(PAPER_NAME)_transition_phase.dvi $(TEXFILES)
	dvips $(DVIPS_PRINTER_OPTS) $(DVIPS_FILE_OPTS) $(PAPER_NAME)_transition_phase.dvi >$(PAPER_NAME)_transition_phase.ps

$(PAPER_NAME).pdf: $(PAPER_NAME).ps $(PAPER_NAME).dvi $(TEXFILES)
	$(PS2PDF) $(PS2PDF_OPTS) $(PAPER_NAME).ps $(PAPER_NAME).pdf

$(PAPER_NAME)_1page_summary.pdf: $(PAPER_NAME)_1page_summary.ps $(PAPER_NAME)_1page_summary.dvi $(TEXFILES)
	$(PS2PDF) $(PS2PDF_OPTS) $(PAPER_NAME)_1page_summary.ps $(PAPER_NAME)_1page_summary.pdf

$(PAPER_NAME)_transition_phase.pdf: $(PAPER_NAME)_transition_phase.ps $(PAPER_NAME)_transition_phase.dvi $(TEXFILES)
	$(PS2PDF) $(PS2PDF_OPTS) $(PAPER_NAME)_transition_phase.ps $(PAPER_NAME)_transition_phase.pdf

clean:
	rm -rf *.bbl *.blg *.dvi *.log *.aux *.idx *~ $(PAPER_NAME).ps $(PAPER_NAME).pdf $(PAPER_NAME)_1page_summary.ps $(PAPER_NAME)_1page_summary.pdf  



